package com.gruppsex.trainingdiary;

import java.io.IOException;

import com.gruppsex.trainingdairy.R;

import android.app.TabActivity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.os.Bundle;
import android.widget.TabHost;

public class StartActivity extends TabActivity {
	private TabHost mTabHost;
	private Boolean firstTime = null;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		overridePendingTransition(R.anim.fadein, R.anim.fadeout);
		setContentView(R.layout.start);

		DataBaseHelper dbHelper = new DataBaseHelper(this);
		try {
			dbHelper.createDataBase();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		mTabHost = getTabHost();
		TabHost.TabSpec spec;
		Intent intent;
		Resources res = getResources();

		boolean firstboot = getSharedPreferences("BOOT_PREF", MODE_PRIVATE)
				.getBoolean("firstboot", true);

		if (firstboot) {
			// 1) Launch the authentication activity
			intent = new Intent(this, ProfileActivity.class);
			spec = mTabHost
					.newTabSpec("Profile")
					.setIndicator("Profile",
							res.getDrawable(R.drawable.pro_icon))
					.setContent(intent);
			mTabHost.addTab(spec);
			// 2) Then save the state
			getSharedPreferences("BOOT_PREF", MODE_PRIVATE).edit()
					.putBoolean("firstboot", false).commit();
		}
		/*
		 * intent = new Intent(this, ProfileActivity.class); spec =
		 * mTabHost.newTabSpec("Profile") .setIndicator("Profile",
		 * res.getDrawable(R.drawable.pro_icon)) .setContent(intent);
		 * mTabHost.addTab(spec);
		 */

		intent = new Intent(this, TestActivity.class);
		intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
		spec = mTabHost
				.newTabSpec("Profile")
				.setIndicator("Planning", res.getDrawable(R.drawable.work_icon))
				.setContent(intent);
		mTabHost.addTab(spec);

		intent = new Intent(this, DayPassActivity.class);
		intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
		spec = mTabHost.newTabSpec("Profile")
				.setIndicator("Workout", res.getDrawable(R.drawable.to_icon))
				.setContent(intent);
		mTabHost.addTab(spec);

		intent = new Intent(this, CalenderActivity.class);
		spec = mTabHost.newTabSpec("Profile")
				.setIndicator("Calendar", res.getDrawable(R.drawable.cal_icon))
				.setContent(intent);
		mTabHost.addTab(spec);

		intent = new Intent(this, StatisticActivity.class);
		spec = mTabHost
				.newTabSpec("Profile")
				.setIndicator("Statistic",
						res.getDrawable(R.drawable.statistic_icon))
				.setContent(intent);
		mTabHost.addTab(spec);
		
		
		intent = new Intent(this, SettingsActivity.class);
		spec = mTabHost.newTabSpec("Profile").setIndicator("Settings",res.getDrawable(R.drawable.settings_icon))
				.setContent(intent);
		mTabHost.addTab(spec);
	}

}
